<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		function test() {
			var i;
			console.log("循环前：" + i);
			for (i = 5; i >= 0; i--) {
				console.log("循环中：" + i);
			}
			console.log("循环后：" + i);
		}

		test();
	</script>

	<script>
		var changeNum;

		changeNum();

		var num = 15;

		/*function changeNum() {
			console.log(num); // undefined
			num = 99;
			console.log(num); // 99
			var num = 1;
			console.log(num); // 1
		}*/

		changeNum = function () {
			console.log(num); // undefined
			num = 99;
			console.log(num); // 99
			var num = 1;
			console.log(num); // 1
		}

		// changeNum();
		console.log(num); // 15
	</script>
</body>
</html>